package com.mnf.server.parser;

import javax.servlet.http.HttpServletRequest;

import com.mnf.server.model.CommandRequest;
import com.mnf.server.model.GetInfoRequest;
import com.mnf.server.model.Request;
import com.mnf.server.model.RequestType;

public class SimpleRequestParser implements HttpRequestParser {

	@Override
	public Request parse(HttpServletRequest httpRequest) {
		String requestUrl = httpRequest.getRequestURL().toString();
		if (requestUrl.contains("getInfo")) {
			return new GetInfoRequest() {
				
				@Override
				public RequestType getRequestType() {
					return RequestType.GET_INFO;
				}
			};
		} else if (requestUrl.contains("command")) {
			return new CommandRequest() {
				
				@Override
				public RequestType getRequestType() {
					return RequestType.COMMAND;
				}
			};
		}
		return null;
	}

}
